package c.j.a.b.a.c;

import android.text.TextUtils;
import c.j.a.a.a.c.d;
import c.j.a.b.a.a.c;
import c.j.a.b.a.a.c.b;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONObject;

/* compiled from: NativeDownloadModel */
public class a {
    public boolean A = false;
    public String B;
    public boolean C = false;
    public String D;
    public String E;
    public boolean F;
    public String G;
    public String H;
    public boolean I;
    public final AtomicBoolean J = new AtomicBoolean(false);
    public final AtomicBoolean K = new AtomicBoolean(false);
    public long L = -1;
    public transient boolean M;
    public int N;
    public long O;
    public long P;
    public long a;
    public long b;
    public String c;
    public int d = 1;
    public String e;
    public String f;
    public String g;
    public int h;
    public int i;
    public int j;
    public int k;
    public String l;
    public String m;
    public boolean n = true;
    public long o;
    public JSONObject p;
    public int q;
    public boolean r = false;
    public int s = 0;
    public int t = 0;
    public long u;
    public long v;
    public long w;
    public int x;
    public int y;
    public String z;

    public static a d(JSONObject jSONObject) {
        a aVar = new a();
        try {
            aVar.a = c.h.a.m0.r.a.a(jSONObject, "mId");
            aVar.b = c.h.a.m0.r.a.a(jSONObject, "mExtValue");
            aVar.c = jSONObject.optString("mLogExtra");
            aVar.d = jSONObject.optInt("mDownloadStatus");
            aVar.e = jSONObject.optString("mPackageName");
            aVar.n = jSONObject.optBoolean("mIsAd");
            aVar.f(c.h.a.m0.r.a.a(jSONObject, "mTimeStamp"));
            aVar.k = jSONObject.optInt("mVersionCode");
            aVar.l = jSONObject.optString("mVersionName");
            aVar.q = jSONObject.optInt("mDownloadId");
            aVar.F = jSONObject.optBoolean("mIsV3Event");
            aVar.N = jSONObject.optInt("mScene");
            aVar.D = jSONObject.optString("mEventTag");
            aVar.E = jSONObject.optString("mEventRefer");
            aVar.f = jSONObject.optString("mDownloadUrl");
            aVar.r = jSONObject.optBoolean("mEnableBackDialog");
            aVar.J.set(jSONObject.optBoolean("hasSendInstallFinish"));
            aVar.K.set(jSONObject.optBoolean("hasSendDownloadFailedFinally"));
            aVar.y = jSONObject.optInt("mLastFailedErrCode");
            aVar.z = jSONObject.optString("mLastFailedErrMsg");
            aVar.g = jSONObject.optString("mOpenUrl");
            aVar.i = jSONObject.optInt("mLinkMode");
            aVar.j = jSONObject.optInt("mDownloadMode");
            aVar.h = jSONObject.optInt("mModelType");
            aVar.m = jSONObject.optString("mAppName");
            aVar.s = jSONObject.optInt("mDownloadFailedTimes", 0);
            aVar.u = c.h.a.m0.r.a.a(jSONObject, "mRecentDownloadResumeTime");
            aVar.t = jSONObject.optInt("mClickPauseTimes");
            aVar.v = c.h.a.m0.r.a.a(jSONObject, "mJumpInstallTime");
            aVar.w = c.h.a.m0.r.a.a(jSONObject, "mCancelInstallTime");
            aVar.x = jSONObject.optInt("mLastFailedResumeCount");
            aVar.H = jSONObject.optString("downloadFinishReason");
            aVar.P = jSONObject.optLong("clickDownloadSize");
            aVar.O = jSONObject.optLong("clickDownloadTime");
            aVar.G = jSONObject.optString("mMimeType");
            aVar.A = jSONObject.optBoolean("mIsUpdateDownload");
            aVar.B = jSONObject.optString("mOriginMimeType");
            aVar.C = jSONObject.optBoolean("mIsPatchApplyHandled");
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            aVar.p = jSONObject.optJSONObject("mExtras");
        } catch (Exception unused) {
            aVar.p = null;
        }
        return aVar;
    }

    public c a() {
        b bVar = new b();
        bVar.a = this.a;
        bVar.b = this.b;
        bVar.e = this.c;
        bVar.f = this.e;
        bVar.i = this.p;
        bVar.c = this.n;
        bVar.o = this.k;
        bVar.p = this.l;
        bVar.j = this.f;
        bVar.d = this.h;
        bVar.l = this.G;
        bVar.k = this.m;
        if (!TextUtils.isEmpty(this.g)) {
            bVar.h = new c.j.a.a.a.e.b(this.g, null, null);
        }
        return bVar.a();
    }

    public c.j.a.b.a.a.b b() {
        c.j.a.b.a.a.b.b bVar = new c.j.a.b.a.a.b.b();
        bVar.a = this.D;
        bVar.k = this.E;
        bVar.j = this.F;
        return bVar.a();
    }

    public c.j.a.b.a.a.a c() {
        c.j.a.b.a.a.a.b bVar = new c.j.a.b.a.a.a.b();
        bVar.c = this.r;
        bVar.a = this.i;
        bVar.b = this.j;
        return bVar.a();
    }

    public long e() {
        long j = this.u;
        return j == 0 ? this.o : j;
    }

    public void f(long j) {
        if (j > 0) {
            this.o = j;
        }
    }

    public a(d dVar, c.j.a.a.a.c.c cVar, c.j.a.a.a.c.b bVar, int i) {
        this.a = dVar.d();
        this.b = dVar.g();
        this.c = dVar.u();
        this.e = dVar.v();
        this.p = dVar.F();
        this.n = dVar.t();
        this.k = dVar.r();
        this.l = dVar.s();
        this.f = dVar.a();
        if (dVar.x() != null) {
            this.g = dVar.x().a;
        }
        this.h = dVar.B();
        this.m = dVar.h();
        this.G = dVar.i();
        this.D = cVar.b();
        this.E = cVar.a();
        this.F = cVar.m();
        this.r = bVar.c();
        this.i = bVar.a();
        this.j = bVar.b();
        this.q = i;
        long currentTimeMillis = System.currentTimeMillis();
        this.o = currentTimeMillis;
        this.u = currentTimeMillis;
        this.B = dVar.i();
        this.C = dVar.A();
    }
}
